<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<%@ include file="/common/taglibs.jsp"%>
<title>基本年度设置</title>
<%@ include file="/common/meta.jsp"%>
<link
	href="${ctx}/assets/plugins/bootstrap-datepicker/css/datepicker.css"
	rel="stylesheet" />
<link
	href="${ctx}/assets/plugins/bootstrap-datepicker/css/datepicker3.css"
	rel="stylesheet" />
<style type="text/css">
.in {
	margin-top: 5px;
}
</style>
</head>
<body>
	<%-- <c:redirect url="/user/list.html"/> --%>
	<!-- begin #page-container -->
	<div id="page-container"
		class="fade page-sidebar-fixed page-header-fixed">
		<!-- #header -->
		<%@ include file="/common/header.jsp"%>
		<!-- #slider -->
		<%@ include file="/common/slider.jsp"%>
		<div class="container" style="margin-left: 270px">
			<div class="panel panel-default">
				<div class="panel-heading">
					<button class="btn" data-toggle="modal" data-target="#myModal">年度设置</button>
				</div>
				<div class="panel-body">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>年度</th>
								<th>开始时间</th>
								<th>结束时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
						<c:forEach var="ls" items="${yearlist}">
							<tr>
								<td>${ls.name}</td>
								<td>${ls.yearBeginDate}</td>
								<td>${ls.name}</td>
								<td><button class="btn">操作</button></td>
							</tr>
						</c:forEach>	
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- end #content -->
	</div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">年度设置</h4>
				</div>
				<div class="modal-body">
					<div class='row form-group in'>
						<label class='control-label col-sm-4' style="text-align: right;">年度名称：</label>
						<div class='col-sm-6 controls'>
							<input type='text' id="yearname">
						</div>
					</div>
					<div class='row form-group in'>
						<label class='control-label col-sm-4' style="text-align: right;">开始时间：</label>
						<div class='col-sm-6 controls'>
							<input type="text" class="form-control" id="datepicker"
								placeholder="请选择开始时间" readonly="true" />
						</div>
					</div>
					<div class='row form-group in'>
						<label class='control-label col-sm-4' style="text-align: right;">结束时间：</label>
						<div class='col-sm-6 controls'>
							<input type="text" class="form-control" id="datepicker2"
								placeholder="请选择开始时间" readonly="true" />
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
					<button type="button" class="btn btn-primary" id="createyear"
						onclick="creatryear()">提交</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>

	<!-- end page container -->
	<%@ include file="/common/footer.jsp"%>

	<script src="${ctx}/assets/js/jquery.datetimepicker.js"></script>
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<!-- END PAGE LEVEL SCRIPTS -->
	<script type="text/javascript">
		$(function() {
			$("#datepicker").datepicker({
				language : "zh-CN",
				autoclose : true,//选中之后自动隐藏日期选择框
				dateFormat : "yy-mm-dd"
			});
			$("#datepicker2").datepicker({
				language : "zh-CN",
				autoclose : true,//选中之后自动隐藏日期选择框
				dateFormat : "yy-mm-dd"
			});
		});

		function creatryear() {
			var yearname = $("#yearname").val();
			var startime = $("#datepicker").val();
			var endtime = $("#datepicker2").val();
			var data = {
					year : yearname,
					startime : startime,
					endtime : endtime
			}

			$.ajax({
				"dataType" : 'json',
				"cache" : false,
				"type" : "POST",
				"data" : data,
				"url" : ctx + "/bastic/setyear",
				"success" : function(data) {
					if (data.type == 'success') {
						alert(data.message);
					} else {
						alert(data.message);
					}
				}
			});
		}
	</script>
</body>
</html>